<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xml:lang="en" lang="en"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:sec="http://www.springframework.org/security/facelets/tags"

        >
<head>
	<link href="css/main.css" media="all" rel="stylesheet" type="text/css" />
</head>

<body>
<h3>Spring Security Facelets taglib example JSF 1.2 + Spring 2</h3>
<br/>

EL-Checktable:
<table border="1">
    <thead>
    <tr>
        <th rowspan="2">Expression</th>

        <th rowspan="2">is</th>
        <th colspan="5">should be</th>
    </tr>
    <tr>
        <th>not logged in</th>
        <th>Jimmi</th>
        <!-- jimi/jimispassword (ROLE_USER, ROLE_ADMIN)  -->
        <th>Bob</th>
        <!-- bob/bobspassword (ROLE_USER) -->
        <th>Steve</th>
        <!-- steve/stevespassword (ROLE_MODERATOR) -->
        <th>Daniel</th>
        <!-- daniel/danielspassword (ROLE_VIEWER) -->
    </tr>
    </thead>


    <tbody>
    <tr>
        <td>sec:ifAnyGranted("ROLE_USER,ROLE_ADMIN"):</td>
        <td class='#{sec:ifAnyGranted("ROLE_USER,ROLE_ADMIN")?"isTrue":"isFalse" }'>
            #{sec:ifAnyGranted("ROLE_USER,ROLE_ADMIN")}
        </td>

        <!-- not logged in -->
        <td class="isFalse">false</td>

        <!-- jimmi -->
        <td class="isTrue">true</td>
        <!-- bob -->
        <td class="isTrue">true</td>
        <!-- steve -->
        <td class="isFalse">false</td>
        <!-- daniel -->
        <td class="isFalse">false</td>
    </tr>

    <tr>
        <td>!sec:ifAnyGranted("ROLE_USER,ROLE_ADMIN"):</td>
        <td class='#{! sec:ifAnyGranted("ROLE_USER,ROLE_ADMIN") ? "isTrue": "isFalse"}'>
            #{! sec:ifAnyGranted("ROLE_USER,ROLE_ADMIN")}
        </td>
        <!-- not logged in -->
        <td class="isTrue">true</td>

        <!-- jimmi -->
        <td class="isFalse">false</td>
        <!-- bob -->
        <td class="isFalse">false</td>
        <!-- steve -->
        <td class="isTrue">true</td>
        <!-- daniel -->
        <td class="isTrue">true</td>
    </tr>

    <tr>
        <td>sec:ifNotGranted("ROLE_USER")</td>
        <td class='#{sec:ifNotGranted("ROLE_USER") ? "isTrue" : "isFalse"}'>#{sec:ifNotGranted("ROLE_USER")}</td>
        <!-- not logged in -->
        <td class="isTrue">true</td>

        <!-- jimmi -->
        <td class="isFalse">false</td>
        <!-- bob -->
        <td class="isFalse">false</td>
        <!-- steve -->
        <td class="isTrue">true</td>
        <!-- daniel -->
        <td class="isTrue">true</td>
    </tr>


    <tr>
        <td>!sec:ifNotGranted("ROLE_USER")</td>
        <td class='#{!sec:ifNotGranted("ROLE_USER") ? "isTrue": "isFalse"}'>#{!sec:ifNotGranted("ROLE_USER")}</td>
        <!-- not logged in -->
        <td class="isFalse">false</td>

        <!-- jimmi -->
        <td class="isTrue">true</td>
        <!-- bob -->
        <td class="isTrue">true</td>
        <!-- steve -->
        <td class="isFalse">false</td>
        <!-- daniel -->
        <td class="isFalse">false</td>
    </tr>
    
    <tr>
        <td>sec:isAnonymous()</td>
        <td class='#{sec:isAnonymous() ? "isTrue": "isFalse"}'>#{sec:isAnonymous()}</td>
        <!-- not logged in -->
        <td class="isTrue">true</td>

        <!-- jimmi -->
        <td class="isFalse">false</td>
        <!-- bob -->
        <td class="isFalse">false</td>
        <!-- steve -->
        <td class="isFalse">false</td>
        <!-- daniel -->
        <td class="isFalse">false</td>
    </tr>
    
    <tr>
        <td>sec:isAuthenticated()</td>
        <td class='#{sec:isAuthenticated() ? "isTrue": "isFalse"}'>#{sec:isAuthenticated()}</td>
        <!-- not logged in -->
        <td class="isFalse">false</td>

        <!-- jimmi -->
        <td class="isTrue">true</td>
        <!-- bob -->
        <td class="isTrue">true</td>
        <!-- steve -->
        <td class="isTrue">true</td>
        <!-- daniel -->
        <td class="isTrue">true</td>
    </tr>

    </tbody>

</table>

<p>
</p>


Tag-Checktable:
<table border="1">
    <thead>
    <tr>
        <th rowspan="2">Code</th>

        <th rowspan="2">is</th>
        <th colspan="5">should be</th>
    </tr>
    <tr>
        <th>not logged in</th>
        <th>Jimmi</th>
        <!-- jimi/jimispassword (ROLE_USER, ROLE_ADMIN)  -->
        <th>Bob</th>
        <!-- bob/bobspassword (ROLE_USER) -->
        <th>Steve</th>
        <!-- steve/stevespassword (ROLE_MODERATOR) -->
        <th>Daniel</th>
        <!-- daniel/danielspassword (ROLE_VIEWER) -->
    </tr>
    </thead>


    <tbody>
    <tr>
        <td>
            &lt;sec:ifAnyGranted roles=&quot;ROLE_USER,ROLE_ADMIN&quot;&gt;
            true
            &lt;/sec:ifAnyGranted&gt;


        </td>
        <td>
            <sec:ifAnyGranted roles="ROLE_USER,ROLE_ADMIN">
                true
            </sec:ifAnyGranted>
        </td>

        <!-- not logged in -->
        <td></td>

        <!-- jimmi -->
        <td>true</td>
        <!-- bob -->
        <td>true</td>
        <!-- steve -->
        <td></td>
        <!-- daniel -->
        <td></td>
    </tr>

    <tr>
        <td>
            &lt;sec:ifAllGranted roles=&quot;ROLE_USER,ROLE_MODERATOR&quot;&gt;
            true
            &lt;/sec:ifAllGranted&gt;
        </td>
        <td>
            <sec:ifAllGranted roles="ROLE_USER,ROLE_MODERATOR">
                true
            </sec:ifAllGranted>
        </td>

        <!-- not logged in -->
        <td></td>

        <!-- jimmi -->
        <td></td>
        <!-- bob -->
        <td></td>
        <!-- steve -->
        <td></td>
        <!-- daniel -->
        <td></td>
    </tr>

    <tr>
        <td>
            &lt;sec:ifNotGranted roles=&quot;ROLE_MODERATOR,ROLE_VIEWER&quot;&gt;
            true
            &lt;/sec:ifNotGranted&gt;
        </td>
        <td>
            <sec:ifNotGranted roles="ROLE_MODERATOR,ROLE_VIEWER">
                true
            </sec:ifNotGranted>
        </td>

        <!-- not logged in -->
        <td>true</td>

        <!-- jimmi -->
        <td>true</td>
        <!-- bob -->
        <td>true</td>
        <!-- steve -->
        <td></td>
        <!-- daniel -->
        <td></td>
    </tr>
    
    <tr>
        <td>
            &lt;sec:isAnonymous&gt;
            true
            &lt;/sec:isAnonymous&gt;
        </td>
        <td>
            <sec:isAnonymous>
                true
            </sec:isAnonymous>
        </td>

        <!-- not logged in -->
        <td>true</td>

        <!-- jimmi -->
        <td></td>
        <!-- bob -->
        <td></td>
        <!-- steve -->
        <td></td>
        <!-- daniel -->
        <td></td>
    </tr>
    
    <tr>
        <td>
            &lt;sec:isAuthenticated&gt;
            true
            &lt;/sec:isAuthenticated&gt;
        </td>
        <td>
            <sec:isAuthenticated>
                true
            </sec:isAuthenticated>
        </td>

        <!-- not logged in -->
        <td></td>

        <!-- jimmi -->
        <td>true</td>
        <!-- bob -->
        <td>true</td>
        <!-- steve -->
        <td>true</td>
        <!-- daniel -->
        <td>true</td>
    </tr>


    </tbody>
</table>
<h2>Selenium Test-Box</h2>
<div id="seleniumData" style="border: 1px solid black; width: 600px;">
    LOGGED_IN: <h:outputText value="#{not empty request.userPrincipal}" /> <br/>
    LOGGEDIN_USERNAME: <h:outputText value="#{request.userPrincipal.name}"/> <br/>
    <hr/>
    TAG_IFANYGRANTED_USER_ADMIN: <sec:ifAllGranted roles="ROLE_USER,ROLE_ADMIN">true</sec:ifAllGranted> <br/>
    TAG_IFALLGRANTED_USER_ADMIN: <sec:ifAllGranted roles="ROLE_USER,ROLE_ADMIN">true</sec:ifAllGranted> <br/>
    TAG_IFNOTGRANTED_USER_ADMIN: <sec:ifNotGranted roles="ROLE_USER,ROLE_ADMIN">true</sec:ifNotGranted> <br/>

    TAG_IFANYGRANTED_USER_MODERATOR: <sec:ifAllGranted roles="ROLE_USER,ROLE_MODERATOR">true</sec:ifAllGranted> <br/>
    TAG_IFALLGRANTED_USER_MODERATOR: <sec:ifAllGranted roles="ROLE_USER,ROLE_MODERATOR">true</sec:ifAllGranted> <br/>
    TAG_IFNOTGRANTED_USER_MODERATOR: <sec:ifNotGranted roles="ROLE_USER,ROLE_MODERATOR">true</sec:ifNotGranted> <br/>

    TAG_IFANYGRANTED_MODERATOR_VIEWER: <sec:ifAllGranted roles="ROLE_MODERATOR,ROLE_VIEWER">true</sec:ifAllGranted> <br/>
    TAG_IFALLGRANTED_MODERATOR_VIEWER: <sec:ifAllGranted roles="ROLE_MODERATOR,ROLE_VIEWER">true</sec:ifAllGranted> <br/>
    TAG_IFNOTGRANTED_MODERATOR_VIEWER: <sec:ifNotGranted roles="ROLE_MODERATOR,ROLE_VIEWER">true</sec:ifNotGranted> <br/>
    
    TAG_ISANONYMOUS: <sec:isAnonymous>true</sec:isAnonymous> <br/>

    TAG_ISAUTHENTICATED: <sec:isAuthenticated>true</sec:isAuthenticated> <br/>

    EL_IFANYGRANTED_USER_ADMIN: #{sec:ifAllGranted("ROLE_USER,ROLE_ADMIN")} <br/>
    EL_IFALLGRANTED_USER_ADMIN: #{sec:ifAllGranted("ROLE_USER,ROLE_ADMIN")} <br/>
    EL_IFNOTGRANTED_USER_ADMIN: #{sec:ifNotGranted("ROLE_USER,ROLE_ADMIN")} <br/>

    EL_IFANYGRANTED_USER_MODERATOR: #{sec:ifAllGranted("ROLE_USER,ROLE_MODERATOR")} <br/>
    EL_IFALLGRANTED_USER_MODERATOR: #{sec:ifAllGranted("ROLE_USER,ROLE_MODERATOR")} <br/>
    EL_IFNOTGRANTED_USER_MODERATOR: #{sec:ifNotGranted("ROLE_USER,ROLE_MODERATOR")} <br/>

    EL_IFANYGRANTED_MODERATOR_VIEWER: #{sec:ifAllGranted("ROLE_MODERATOR,ROLE_VIEWER")} <br/>
    EL_IFALLGRANTED_MODERATOR_VIEWER: #{sec:ifAllGranted("ROLE_MODERATOR,ROLE_VIEWER")} <br/>
    EL_IFNOTGRANTED_MODERATOR_VIEWER: #{sec:ifNotGranted("ROLE_MODERATOR,ROLE_VIEWER")} <br/>
    
    EL_ISANONYMOUS: #{sec:isAnonymous()} <br/>

    EL_ISAUTHENTICATED: #{sec:isAuthenticated()} <br/>

</div>
</body>
</html>
